package net.hn.hnms.biz.plan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.plan.domain.PlanOther;
import net.hn.hnms.biz.plan.vo.PlanOtherVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface PlanOtherMapper extends BaseMapper<PlanOther> {

    @Select("<script>" +
            "  select case when count(other_plan_id) > 0 then count(other_plan_id)   else null end  as totalPlan," +
            " min(plan_start_date) as planStartDate, " +
            " max(plan_end_date) as planEndDate ," +
            " sum(plan_repair) as totalPlanRepair," +
            " sum(plan_grout) as totalPlanGrout," +
            " sum(plan_nitrogen) as totalPlanNitrogen," +
            " sum(plan_gasext) as totalPlanGasext," +
            " sum(plan_material) as totalPlanMaterial," +
            " sum(plan_recycle) as totalPlanRecycle," +
            " sum(plan_water) as totalPlanWater," +
            " sum(plan_power) as totalPlanPower" +
            " from plan_other where del_flag ='0' and status ='0'  and  mine_code = #{mineCode} " +
            "</script>")
    PlanOtherVO selectOtherTotalByMineCode(@Param("mineCode") String mineCode);

    @Select("<script>" +
            "  select case when count(other_plan_id) > 0 then count(other_plan_id)   else null end  as totalPlan," +
            " min(plan_start_date) as planStartDate, " +
            " max(plan_end_date) as planEndDate ," +
            " sum(plan_repair) as totalPlanRepair," +
            " sum(plan_grout) as totalPlanGrout," +
            " sum(plan_nitrogen) as totalPlanNitrogen," +
            " sum(plan_gasext) as totalPlanGasext," +
            " sum(plan_material) as totalPlanMaterial," +
            " sum(plan_recycle) as totalPlanRecycle," +
            " sum(plan_water) as totalPlanWater," +
            " sum(plan_power) as totalPlanPower" +
            " from plan_other where del_flag ='0' and status ='0'  and  company_code = #{mineCode} " +
            "</script>")
    PlanOtherVO selectDrivageTotalByCompanyCodeOrName(@Param("mineCode") String mineCode);
}
